/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ucsur.libreriaelsaber.actions;

import edu.ucsur.libreriaelsaber.data.DAOFactory;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author Administrator
 */
public class LogoutAction extends Action {
  
  //Instanciando el DAOFactory (clase que se encarga de fabricar los objetos DAO)
  private DAOFactory factory = DAOFactory.getFactory(DAOFactory.TIPO_MYSQL);
  
  public ActionForward execute(ActionMapping mapping, ActionForm form,
                               HttpServletRequest request,
                               HttpServletResponse response) throws Exception {
    //Destruir la sesión actual
    request.getSession().invalidate();
    //Redireccionar al login (sin Request Dispatcher, ya que la sesión ya murió)
    return mapping.getInputForward();
  }
  
}
